package com.yyy.dm.consumer.service;

import com.yyy.dm.CommonResponse;
import com.yyy.dm.VoUtil;
import com.yyy.dm.dao.SchedulerSeatMapper;
import com.yyy.dm.dao.SchedulerSeatPriceMapper;
import com.yyy.dm.scheduler.SchedulerSeatDTO;
import com.yyy.dm.scheduler.SchedulerSeatInfoDTO;
import com.yyy.dm.scheduler.SchedulerSeatPriceDTO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

@Service
public class SchedulerSeatConsumerService {
    @Resource
    private SchedulerSeatPriceMapper schedulerSeatPriceMapper;
    @Resource
    private SchedulerSeatMapper schedulerSeatMapper;

    public CommonResponse getSchedule(Long cinemaId,Long scheduleId){
        List<SchedulerSeatPriceDTO> schedulerSeatPriceDTOList = schedulerSeatPriceMapper.findSchedulerSeatPriceByScheduleId(scheduleId);
        List<SchedulerSeatInfoDTO> schedulerSeatInfoDTOList = schedulerSeatMapper.findSchedulerSeatInfoByScheduleId(new HashMap(){{
            put("cinemaId",cinemaId);
            put("scheduleId",scheduleId);
        }});
        SchedulerSeatDTO schedulerSeatDTO = new SchedulerSeatDTO();
        schedulerSeatDTO.setCinemaId(cinemaId);
        schedulerSeatDTO.setScheduleId(scheduleId);
        schedulerSeatDTO.setSeatInfoList(schedulerSeatInfoDTOList);
        schedulerSeatDTO.setSeatPriceList(schedulerSeatPriceDTOList);
        return VoUtil.returnSuccess(schedulerSeatDTO);
    }
}
